package com.amex.uam.dao.impl;

import java.util.List;

import org.springframework.jdbc.core.PreparedStatementSetter;
import org.springframework.stereotype.Repository;

import com.amex.uam.dao.GeoDao;
import com.amex.uam.model.MS_USER_CTRY_ACSS;
import com.amex.uam.model.MS_USER_RGN_ACSS;
@Repository("geoDao")
public class GeoDaoImpl extends JdbcDao implements GeoDao {

	@Override
	public boolean addUserRegion(MS_USER_RGN_ACSS region) {
		String insertSQL = "insert into MS_USER_RGN_ACSS(WORKFORCE_MBR_ID, RGN_ABBR_NM, CREAT_TS) values(?,?,?)"; 
		Object[] params = {region.getWORKFORCE_MBR_ID(), region.getRGN_ABBR_NM(), region.getCREAT_TS()};
		int result = this.getJdbcTemplate().update(insertSQL, params);
		return result > 0;
	}
	
	@Override
	public boolean addUserRegion(List<MS_USER_RGN_ACSS> list) {
		
		if (list == null) {
			return true;
		}
		
		for (int i = 0; i < list.size(); i++) {
			addUserRegion(list.get(i));
		}
		
		return true;
	}

	@Override
	public boolean addUserCountry(MS_USER_CTRY_ACSS country) {
		String insertSQL = "insert into MS_USER_CTRY_ACSS(WORKFORCE_MBR_ID, CTRY_NM, CREAT_TS) values(?,?,?)"; 
		Object[] params = {country.getWORKFORCE_MBR_ID(), country.getCTRY_NM(), country.getCREAT_TS()};
		this.getJdbcTemplate().update(insertSQL, params);
		return false;
	}

	@Override
	public boolean addUserCountry(List<MS_USER_CTRY_ACSS> list) {
		
		if (list == null) {
			return true;
		}
		
		for (int i = 0; i < list.size(); i++) {
			addUserCountry(list.get(i));
		}
		
		return true;
	}
	
	
}
